/**
 * @description 通告处理层
 */
const {
    createNotice,
    getNoticeList
} = require('../services/notice')
const {
    SuccessModel,
    ErrorModel
} = require('../model/ResModel')

const noticeList = async ({province, city, type}) => {
    const result = await getNoticeList({province, city, type})
    return new SuccessModel(result)
    // let sql = `
    //             select * from notice where 1=1
    // `
    // sql += province == '全国' ? '' : `and province=${escape(province)} `
    // sql += city == '全部' ? '' : `and city=${escape(city)} `
    // sql += type == '全部' ? '' : `and type like '%${type}%'; `
    // console.log(sql);

    // return listData = await exec(sql)
}

/**
 * @description 创建通告
 * @param {object} param0 
 */
async function noticeAdd({
    userId,
    title,
    content,
    type,
    province,
    city,
    phone,
    weChat,
    activityTime
}) {
    const createTime = new Date().getTime()
    console.log(createTime)
    const result =await createNotice({
        userId,
        title,
        content,
        type,
        province,
        city,
        phone,
        weChat,
        activityTime,
        createTime
    })
    return new SuccessModel(result)
}



module.exports = {
    noticeList,
    noticeAdd
}